package com.czp.framework.action;

import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;


/**
 * 【环 境】：J2SE 1.7
 * 
 * @author   柴志鹏
 * @version  version 1.0
 * @since    2014-4-29
 */
public class BaseActionSupport extends ActionSupport implements SessionAware,
												ServletRequestAware {
	private static final long serialVersionUID = 7314482337978093560L;
	protected Map<String, Object> session;
	protected HttpServletRequest request;
	
	/** 
	 * 【描 述】：页面输出数据
	 * @param object
	 * @throws Exception
	 */
	protected void responseOutPrint(Object object) throws Exception {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		//application/json    text/html
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = null;
		try {
			out = response.getWriter();
			out.print(object);
		} catch (Exception e) {
			throw e;
		} finally {
			if (out != null) {out.close();}
		}
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

}
